import { Component, OnInit } from '@angular/core';
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
import { StageService } from './stage.service';

import * as moment from 'moment';
import * as _ from 'lodash'

@Component({
	selector: 'app-stage',
	templateUrl: './stage.component.html',
	styleUrls: ['./stage.component.scss'],
	providers: [StageService]
})
export class StageComponent implements OnInit {

	public stageList = [];

	public listCount = 20;

	public type = 0;

	public selectdType = 1;

	constructor(
		private stageStageService: StageService,
		public router: Router,
		private route: ActivatedRoute,
	) {
		this.route.params.subscribe((data) => {
			console.info(data);
			this.type = parseInt(data.type);
			this.initList(this.type);
		});
	}

	view() {
		// window["$"]("#content-main-modal").modal();
		// document.getElementById("content-main-modal-iframe")['src'] = "product/detail/edit/a";
		// window.open('/product/detail/edit/a');
		window['currentTitle'] = '产品详情';
		this.router.navigate(['pages/dashboard/p/detail/edit/a']);
		window.scrollTo(0, 0);
	}

	initList(type) {
		this.stageList = [];
		let groupType = "";
		if (type === 1) {
			groupType = "产品合同";
		} else if (type === 2) {
			groupType = "招募说明书";
		} else if (type === 3) {
			groupType = "代销协议";
		} else if (type === 4) {
			groupType = "托管协议";
		} else if (type === 5) {
			groupType = "备案函";
		} else if (type === 6) {
			groupType = "开户材料";
		}
		for (var i = 1; i <= this.listCount; i++) {
			this.stageList.push({
				name: '董事会决议' + i + '.docx',
				groupType: groupType,
				dept: '三组' + i,
				user: '王二强',
				time: "2017-5-3 07:28:47"
			});
		}
	}

	ngOnInit() {

		// this.stageList = this.stageStageService.list();
	}

	showModal() {
		window['$']("#stage-modal").modal();
	}

}
